<?php
namespace WebApper\Shortcode;

/*
 * [service]
 *
 */
 class ReportingClient extends \WebApper\Shortcode {
	
    /**
     * Define shortcode properties
     *
     */
	protected $shortcode = 'reportingClient';

    /**
     * Initialize the Shortcode Class
     *
     */
    public function __construct() {
		add_shortcode( $this->shortcode, array($this, 'shortcode') );
		add_action( 'wp_ajax_web_apper' . $this->shortcode, array($this, 'sendAjaxResponse') );
		add_action( 'wp_ajax_nopriv_web_apper' . $this->shortcode, array($this, 'sendAjaxResponse') );	   	
	}

    /**
     * Handles the add post shortcode
     *
     * @param array $atts
     */
	 
    public function shortcode( $atts ) {		
		
		extract( shortcode_atts( $this->defaults, $atts ) );
		 global $wpdb, $webapper;
        
		?>
<div class="span10">
<h3>Reporting Client</h3>
  <table id="reportingClient" class="table table-bordered table-striped" >
    <thead>
      <tr>
        <th>Client </th>
        <th>Amount Paid</th>
        <th>Balance</th>
        <th>status</th>
        <th>Default Amount</th>
        <th>Consult Rep Assigned To</th>
        <th>Notes</th>
      </tr>
    </thead>
    <tbody>
    <?php
	$user_id = get_current_user_id();
   	$client_payment_transaction = $webapper->tables->client_payment_transaction;
	$client_query = $wpdb->get_results("SELECT * FROM {$client_payment_transaction} WHERE user_id='$user_id' ORDER BY id ASC");
	foreach ($client_query as $row ):
	
		           echo '<tr >';
                   echo '<td>' .stripslashes($row ->client_name) . '</td>';
                   echo '<td>' .$row ->amount_paid. '</td>';
                   echo '<td>' .$row ->balance . '</td>';
				   echo '<td>' .stripslashes($row ->status_active) . '</td>';
				   echo '<td>' .$row ->default_amount . '</td>';
				   echo '<td>' .stripslashes($row ->consult_rep_assigned_to) . '</td>';
				   echo '<td>' .stripslashes($row ->notes) . '</td>';
				   echo '</tr>';
	  endforeach;
	?>
    </tbody>
  </table>
</div>
</div>
	<script type="text/javascript">
    	nTable = jQuery('#reportingClient');
		jQuery(document).ready(function($){
			// Initialize dataTable					
					oTable = $(nTable).dataTable({
						<?php
					     global $template;
							if ( stristr($template, 'fullwidth') ) :
								$spanA = 7; $spanB = 7;
							else :
								$spanA = 4; $spanB = 5;
							endif;
							echo "'sDom': \" <'row' <'span1' C><'span9'fl>r>t<'row'<'span6'i><'span4'p>>\",\n";
						?>
						'sPaginationType': 'bootstrap',
						'aaSorting': [[ 0,1,2,5, 'asc']],
						'oLanguage': {
							'sLengthMenu': 'Records per page <select>'+
							'<option value="10">10</option>'+
							'<option value="20">20</option>'+
							'<option value="30">30</option>'+
							'<option value="40">40</option>'+
							'<option value="50">50</option>'+
							'<option value="100">100</option>'+
							'</select>'
						},
						//'aoColumnDefs': [ { 'bVisible': false, 'aTargets': [  2, ] } ],
						'oColVis': {
							'buttonText': 'Columns',
							'bRestore': true,
							'sAlign': 'left',
							'sSize': 'css',
							'aiExclude': [ 0,]	
						},
					});		
		});
    </script>

<?php	
	}		
}
$initialize = new reportingClient(); 

?>
